package com.hkx.util;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import com.hkx.core.BaseEntity;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

public class Coding {
    public static void main(String[] args) {
        String basePath = System.getProperty("user.dir");
        String table = "role";
        String url = "jdbc:mysql://192.168.80.130:3306/shop";
        FastAutoGenerator.create(url, "root", "123456")
                .globalConfig(i -> {
                    i.author("huangkexing")
                            .disableOpenDir()
                            .outputDir(basePath + "/src/main/java");
                })
                .packageConfig(i -> {
                    Map<OutputFile, String> pathInfo = new HashMap<>();
                    pathInfo.put(OutputFile.xml, basePath + "/src/main/resources/com/hkx/mapper");
                    i.parent("com.hkx")
                            .pathInfo(pathInfo);
                }).strategyConfig(i -> {
                    i.addInclude(table);
                    i.entityBuilder()
                            .enableLombok()
                            .superClass(BaseEntity.class)
                            .addSuperEntityColumns("id")
                            .naming(NamingStrategy.underline_to_camel)
                            .columnNaming(NamingStrategy.underline_to_camel)
                            .controllerBuilder()
                            .enableRestStyle()
                            .serviceBuilder()
                            .formatServiceFileName("%sService");
                }).templateEngine(new FreemarkerTemplateEngine())
                .execute();

    }
}
